package com.galen.manual.vo;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 用户管理视图对象
 */
@Data
@Schema(description = "用户管理信息")
public class UserManageVO {

    @Schema(description = "用户ID", example = "123456")
    private Long id;

    @Schema(description = "用户名", example = "admin")
    private String username;

    @Schema(description = "昵称", example = "张三")
    private String nickname;

    @Schema(description = "真实姓名", example = "张三")
    private String realName;

    @Schema(description = "手机号", example = "13800138000")
    private String phone;

    @Schema(description = "头像URL", example = "http://example.com/avatar.jpg")
    private String avatarUrl;

    @Schema(description = "地址", example = "北京市朝阳区")
    private String address;

    @Schema(description = "用户等级：1-普通用户，2-高级用户，3-VIP用户", example = "1")
    private Integer userLevel;

    @Schema(description = "用户等级名称", example = "普通用户")
    private String userLevelName;

    @Schema(description = "用户状态：0-待审核，1-正常，2-冻结，3-黑名单", example = "1")
    private Integer status;

    @Schema(description = "用户状态名称", example = "正常")
    private String statusName;

    @Schema(description = "累计完成数量", example = "100")
    private Integer totalCompleted;

    @Schema(description = "累计收益", example = "1000.50")
    private BigDecimal totalEarnings;

    @Schema(description = "账户余额", example = "500.00")
    private BigDecimal balance;

    @Schema(description = "是否为管理员", example = "false")
    private Boolean isAdmin;

    @Schema(description = "管理员角色", example = "admin")
    private String adminRole;

    @Schema(description = "注册时间", example = "2023-01-01 10:00:00")
    private LocalDateTime createTime;

    @Schema(description = "最后登录时间", example = "2023-01-01 15:30:00")
    private LocalDateTime lastLoginTime;

    @Schema(description = "最后登录IP", example = "192.168.1.1")
    private String lastLoginIp;

    /**
     * 获取用户等级名称
     */
    public String getUserLevelName() {
        if (this.userLevel == null) return "未知";
        switch (this.userLevel) {
            case 1: return "普通用户";
            case 2: return "高级用户";
            case 3: return "VIP用户";
            default: return "未知";
        }
    }

    /**
     * 获取用户状态名称
     */
    public String getStatusName() {
        if (this.status == null) return "未知";
        switch (this.status) {
            case 0: return "待审核";
            case 1: return "正常";
            case 2: return "冻结";
            case 3: return "黑名单";
            default: return "未知";
        }
    }
}